import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ContractTypeVO, ContractTypeForm, ContractTypeQuery } from '@/api/goods/invoicingMethod/types';

/**
 * 查询合同类型列表
 * @param query
 * @returns {*}
 */

export const listContractType = (query?: ContractTypeQuery): AxiosPromise<ContractTypeVO[]> => {
  return request({
    url: '/order/contractType/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询合同类型详细
 * @param id
 */
export const getContractType = (id: string | number): AxiosPromise<ContractTypeVO> => {
  return request({
    url: '/order/contractType/' + id,
    method: 'get'
  });
};

/**
 * 新增合同类型
 * @param data
 */
export const addContractType = (data: ContractTypeForm) => {
  return request({
    url: '/order/contractType',
    method: 'post',
    data: data
  });
};

/**
 * 修改合同类型
 * @param data
 */
export const updateContractType = (data: ContractTypeForm) => {
  return request({
    url: '/order/contractType',
    method: 'put',
    data: data
  });
};

/**
 * 删除合同类型
 * @param id
 */
export const delContractType = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/contractType/' + id,
    method: 'delete'
  });
};

export default {
  list:listContractType,

  get:getContractType,
  add:addContractType,

  update:updateContractType,
  del:delContractType,
}